<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Colors</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GDK 3 参考手册">
<link rel="up" href="reference.html" title="API参考">
<link rel="prev" href="gdk3-Pixbufs.html" title="Pixbufs">
<link rel="next" href="gdk3-RGBA-Colors.html" title="RGBA Colors">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gdk3-Pixbufs.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GDK 3 参考手册</th>
<td><a accesskey="n" href="gdk3-RGBA-Colors.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gdk3-Colors.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#gdk3-Colors.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="gdk3-Colors"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gdk3-Colors.top_of_page"></a>Colors</span></h2>
<p>Colors — Manipulation of colors</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="gdk3-Colors.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gdk/gdk.h&gt;

                    <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor">GdkColor</a>;
<a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="returnvalue">GdkColor</span></a> *          <a class="link" href="gdk3-Colors.html#gdk-color-copy" title="gdk_color_copy ()">gdk_color_copy</a>                      (<em class="parameter"><code>const <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *color</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gdk3-Colors.html#gdk-color-free" title="gdk_color_free ()">gdk_color_free</a>                      (<em class="parameter"><code><a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *color</code></em>);
<a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="gdk3-Colors.html#gdk-color-parse" title="gdk_color_parse ()">gdk_color_parse</a>                     (<em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *spec</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *color</code></em>);
<a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="gdk3-Colors.html#gdk-color-equal" title="gdk_color_equal ()">gdk_color_equal</a>                     (<em class="parameter"><code>const <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *colora</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *colorb</code></em>);
<a href="../glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a>               <a class="link" href="gdk3-Colors.html#gdk-color-hash" title="gdk_color_hash ()">gdk_color_hash</a>                      (<em class="parameter"><code>const <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *color</code></em>);
<a href="../glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> *             <a class="link" href="gdk3-Colors.html#gdk-color-to-string" title="gdk_color_to_string ()">gdk_color_to_string</a>                 (<em class="parameter"><code>const <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *color</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="gdk3-Colors.description"></a><h2>Description</h2>
<p>
A <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> represents a color.
</p>
<p>
When working with cairo, it is often more convenient
to use a <a class="link" href="gdk3-RGBA-Colors.html#GdkRGBA" title="GdkRGBA"><span class="type">GdkRGBA</span></a> instead.
</p>
</div>
<div class="refsect1">
<a name="gdk3-Colors.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="GdkColor"></a><h3>GdkColor</h3>
<pre class="programlisting">typedef struct {
  guint32 pixel;
  guint16 red;
  guint16 green;
  guint16 blue;
} GdkColor;
</pre>
<p>
The <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> structure is used to describe a color,
similar to the XColor struct used in the X11 drawing API.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><a href="../glib/glib-Basic-Types.html#guint32"><span class="type">guint32</span></a> <em class="structfield"><code><a name="GdkColor.pixel"></a>pixel</code></em>;</span></p></td>
<td>For allocated colors, the pixel value used to
draw this color on the screen. Not used anymore.</td>
</tr>
<tr>
<td><p><span class="term"><a href="../glib/glib-Basic-Types.html#guint16"><span class="type">guint16</span></a> <em class="structfield"><code><a name="GdkColor.red"></a>red</code></em>;</span></p></td>
<td>The red component of the color. This is
a value between 0 and 65535, with 65535 indicating
full intensitiy</td>
</tr>
<tr>
<td><p><span class="term"><a href="../glib/glib-Basic-Types.html#guint16"><span class="type">guint16</span></a> <em class="structfield"><code><a name="GdkColor.green"></a>green</code></em>;</span></p></td>
<td>The green component of the color</td>
</tr>
<tr>
<td><p><span class="term"><a href="../glib/glib-Basic-Types.html#guint16"><span class="type">guint16</span></a> <em class="structfield"><code><a name="GdkColor.blue"></a>blue</code></em>;</span></p></td>
<td>The blue component of the color</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-color-copy"></a><h3>gdk_color_copy ()</h3>
<pre class="programlisting"><a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="returnvalue">GdkColor</span></a> *          gdk_color_copy                      (<em class="parameter"><code>const <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *color</code></em>);</pre>
<p>
Makes a copy of a color structure.
</p>
<p>
The result must be freed using <a class="link" href="gdk3-Colors.html#gdk-color-free" title="gdk_color_free ()"><code class="function">gdk_color_free()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>color</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a copy of <em class="parameter"><code>color</code></em>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-color-free"></a><h3>gdk_color_free ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gdk_color_free                      (<em class="parameter"><code><a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *color</code></em>);</pre>
<p>
Frees a color structure created with <a class="link" href="gdk3-Colors.html#gdk-color-copy" title="gdk_color_copy ()"><code class="function">gdk_color_copy()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>color</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a>
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-color-parse"></a><h3>gdk_color_parse ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            gdk_color_parse                     (<em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *spec</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *color</code></em>);</pre>
<p>
Parses a textual specification of a color and fill in the
<em class="structfield"><code>red</code></em>, <em class="structfield"><code>green</code></em>,
and <em class="structfield"><code>blue</code></em> fields of a <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a>
structure.
</p>
<p>
The string can either one of a large set of standard names
(taken from the X11 <code class="filename">rgb.txt</code> file), or
it can be a hex value in the form '#rgb' '#rrggbb'
'#rrrgggbbb' or '#rrrrggggbbbb' where 'r', 'g' and
'b' are hex digits of the red, green, and blue components
of the color, respectively. (White in the four forms is
'#fff', '#ffffff', '#fffffffff' and
'#ffffffffffff').
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>spec</code></em> :</span></p></td>
<td>the string specifying the color</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>color</code></em> :</span></p></td>
<td>the <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> to fill in. <span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a href="../glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the parsing succeeded</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-color-equal"></a><h3>gdk_color_equal ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            gdk_color_equal                     (<em class="parameter"><code>const <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *colora</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *colorb</code></em>);</pre>
<p>
Compares two colors.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>colora</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>colorb</code></em> :</span></p></td>
<td>another <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a href="../glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the two colors compare equal</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-color-hash"></a><h3>gdk_color_hash ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a>               gdk_color_hash                      (<em class="parameter"><code>const <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *color</code></em>);</pre>
<p>
A hash function suitable for using for a hash
table that stores <a href="gdk3-Colors.html#GdkColor"><span class="type">GdkColors</span></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>color</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>The hash function applied to <em class="parameter"><code>color</code></em>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-color-to-string"></a><h3>gdk_color_to_string ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> *             gdk_color_to_string                 (<em class="parameter"><code>const <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a> *color</code></em>);</pre>
<p>
Returns a textual specification of <em class="parameter"><code>color</code></em> in the hexadecimal form
<code class="literal">#rrrrggggbbbb</code>, where <code class="literal">r</code>,
<code class="literal">g</code> and <code class="literal">b</code> are hex digits
representing the red, green and blue components respectively.
</p>
<p>
The returned string can be parsed by <a class="link" href="gdk3-Colors.html#gdk-color-parse" title="gdk_color_parse ()"><code class="function">gdk_color_parse()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>color</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-Colors.html#GdkColor" title="GdkColor"><span class="type">GdkColor</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a newly-allocated text string</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.12</p>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>